home *** CD-ROM | disk | FTP | other *** search
- Path: nntp.teleport.com!sschaem
- From: sschaem@teleport.com (Stephan Schaem)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: PPC compilers
- Date: 12 Jan 1996 12:29:05 GMT
- Organization: Teleport - Portland's Public Access (503) 220-1016
- Message-ID: <4d5k6h$a2j@maureen.teleport.com>
- References: <john.hendrikx.40ka@grafix.xs4all.nl> <jasonb.820051107@cs.uwa.edu.au> <VBzVx*M3f@yaps.rhein.de> <4d0tf0$i4i@maureen.teleport.com> <jasonb.821371468@cs.uwa.edu.au>
- NNTP-Posting-Host: linda.teleport.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Jason S Birch (jasonb@cs.uwa.edu.au) wrote:
- : sschaem@teleport.com (Stephan Schaem) writes:
-
- : >Arno Eigenwillig (arno@yaps.rhein.de) wrote:
- : >: Don't distract, this was not the point. Intentional misunderstandings
- : >: prove nothing.
-
- : > It was about: "C is better because you dont need to know your variable type"
-
- : No, it wasn't, which is what I've been repeatedly saying. It was about
- : whether assembler is easier to debug than C because the line:
-
- : move.w (a0)+,(a1)+
-
- : tells you how many bytes are being moved, and added to a0 and a1,
- : whereas:
-
- It tells me that I move a word from a0 to a1 and let point a0 and a1 to
- the next word. (I just happen to know word is 2 byte:)
-
- : *a++ = *b++;
-
- : does not. Many of us said "no", not least because the assembler line
- : doesn't tell you whether you *wanted* to move two bytes or not unless
- : you know what a0 and a1 are pointing to. You need to know that to know
- : if it's correct, just as you need to know that *a and *b are the same
- : type, although in the C case you *don't* need to know how many bytes
- : are moved or added to a and b - you don't need to know how the types
- : are *implemented*, and the claim was made that, in any case, you could
- : pretty much rely on C to complain if you make a mistake. This is where
- : you came in. Note the difference between "not needing to know your
- : variable type" and "not needing to know how that variable type is
- : implemented on a particular hardware/OS/compiler implementation".
-
- Notice I didn't mention type size for asm or C... And where we not talking
- about debuging already compiled code, right? I recall we where talking
- about writting code.
-
- I will repeat:
-
- move.word (a0)+,(a1)+
-
- I would not write the above if I didn't know a0 and a1 are of the same type.
-
- a++ = b++
-
- I would not write the above if I didn't know a and b are of the same type,
- or a type compatible with C operators, or a type that can be converted..
-
- basicly in both case know the variable type, and type definition.
-
- Thats all I'm saying... I attacked the asm and C person first claim on
- the subject.
-
- : >: What are you talking about? <time.h> is provided as part of the
- : >: compiler. The compiler is a beast that translates a valid C source
- : >: code defining an algorithm for an abstract machine into actual machine
- : >: code for an actual machine.
-
- : > I'm talking about doing operation on a strcuture element. if the element
- : > was defined has a ulong, then one decide its a float you will have to
- : > update your code too to use float.
-
- : This is a red herring. If the *type* of an element in a structure is
- : given as ulong, then it must be a ulong, it is bound to being a ulong,
- : and you can forever more treat it as a ulong. If it's given as a
- : bilby, however, and somewhere else a bilby is defined to be a ulong
- : (via typedef), then it is only bound to being a bilby and you can only
- : treat it like a bilby - you may not treat it as a ulong.
-
- Yes, and I read that clock_t was a ulong...
-
- Maybe I dont give the image of it but I know C too. (I wont make that claim
- for c++)
-
- : Note well, however, that even ulong is an abstract type, and the only
- : assumptions you can make about it are those guaranteed by ANSI
- : (assuming you want portability, of course). In particular, it is *not*
- : guaranteed to be a 32 bit unsigned integer. On a DEC Alpha, for
- : example, it's 64 bits. On a 16 bit machine, it could well be 16 bits.
- : Look at integer for another example - on a 68000 Amiga with SAS/C, it
- : defaults to 32 bits; specify SHORTINTEGERS and it's 16 bits. On a Mac,
- : it's 16 bits. Win16 code on a PC, it's 16 bits; compile for Win32 and
- : it's 32 bits. The reason for not specifying these sizes is efficiency
- : - leaving them undefined allows the compiler writer to choose the most
- : efficient representation. Unfortunately, it requires the programmer to
- : do more work to make sure the types can hold the values required. It
- : would make writing portable code easier if there were int16, int32,
- : int64, etc, types, but this is a side issue. :-)
-
- Yes... I rely on ANSI standart of min range assigned ...
- In asm the range are fixed it just happen to be that way, and nobody
- bothered to offer a #typedef function.(a Virtual .int type could have been
- created for the 68000 and now be implemented in HW with 64bit register
- otherwise used has a word or long depanding on your assembler setting)
- I mentioned all that early on in my post. I also mentioned that I write
- common code for windows & macos, So I would hope to know about making code
- portable...
-
- : >: The idea behind clock_t is that it is a data type suitable for storage
- : >: of the system's clock's value and certain operations on it. These
- : >: operations are defined in an abstract way, independant of a specific
- : >: choice what simple type clock_t may actually be.
-
- : > you might not care clockt_t went from 32bit long to a 64bit long,
- : > but I you would if it become a 32digit bcpl.
-
- : It couldn't, because "-" would no longer work; however, if a
- : DiffClock() function existed, it could. time_t is a better example.
-
- This is also true for asm...
-
- : >: Dave called it "polymorphism". I call it "data encapsulation". Anyway,
- : >: it's a basic concept of decent programming, and not having understood
- : >: it is no crime, but one probably shouldn't go around demonstrating it
- : >: everywhere in the most embarrassing way. Eh?
-
- : > The point he wanted to prove is that you dont need to care about your
- : > variable type, and your variable type definition. I just desagree.
-
- : This is the problem - he never wanted to prove that. You misinterpreted
- : his comments, and have thus far refused to give up your straw man. :-)
-
- Ok then... its just that when I saw something, and one respond "no you
- are wrong" + detail, I like to prove my original point. I fell strong
- about it because this fact ahappen on everyline I write in ASM or C.
- So someone telling me (Or me reading) that I dont have to bother with type
- definition and even variable type after I define:declare them turn my
- world around :)
-
- Stephan
-